<template>
  <div class="lottery">
    <!--上方卡片部分-->
    <div class="card">
      <template v-for="(item, index) in cardList">
        <div class="card-item" :key="index">
          <div class="title">{{ item.title }}</div>
          <div class="txt">{{ item.text }}</div>
          <!-- <permission authority="lottery:manager:addLottery"> -->
          <!-- <div class="btn" @click="creatActive()">立即新建</div> -->
          <a-button
            style="margin-top: 15px"
            type="primary"
            icon="plus"
            @click="creatActive(item.key)"
            >立即新建</a-button
          >
          <!-- </permission> -->
        </div>
      </template>
    </div>
    <!--下部列表-->
    <!-- <div class="tables">
      <div class="tabs">
        <template v-for="(item, index) in cardList">
          <div
            class="btn-item"
            :key="index"
            v-if="item.show"
            @click="selectTab(item)"
          >
            {{ item.title }}
          </div>
        </template>
      </div> -->
    <div style="position: relative">
      <a-tabs type="card" :activeKey="activeKey" @change="tabsChange">
        <a-tab-pane v-for="item in cardList" :key="item.key" :tab="item.title">
          <lottery-table></lottery-table>
        </a-tab-pane>
      </a-tabs>
      <a-button class="exchangeLog" @click="goExchangeList">兑换记录</a-button>
    </div>
  </div>
</template>

<script>
import lotteryTable from "@views/menuPage/marketing/lottery/page/lotteryTable.vue";
export default {
  name: "MarketingLottery",
  components: {
    lotteryTable,
  },
  data() {
    return {
      cardList: [
        // 现阶段只有盲盒抽奖功能
        { title: "盲盒抽奖", text: "幸运大转盘，赢取大豪礼", key: 1 },
        // { title: "幸运扭蛋机", text: "", key: 2 },
        // { title: "开福袋赢大奖", text: "", key: 3 },
        // { title: "开心抓娃娃", text: "", key: 4 },
        // { title: "幸运大转盘", text: "", key: 5 },
      ],
      activeKey: 1,
    };
  },
  // 方法集合
  methods: {
    selectTab(item) {
      this.$message.info(item.title);
    },
    // 新建活动
    creatActive(key) {
      this.$router.push({
        name: "MarketingLotteryPageCreatActive",
        query: {
          lotteryType: key,
        },
      });
    },
    tabsChange(val) {
      this.activeKey = val;
    },
    goExchangeList() {
      this.$router.push({
        name: "MarketingLotteryPageExchangeList",
      });
    },
  },
};
</script>
<style lang="less" scoped>
.lottery {
  .card {
    margin-bottom: 20px;
    display: flex;
    overflow: scroll;
    background: #eee;
    border-radius: 8px;
    padding: 10px 8px;
    .card-item {
      flex-shrink: 0;
      width: 25%;
      height: 180px;
      box-sizing: border-box;
      text-align: center;
      background: #fff;
      padding: 24px;
      // border: 1px solid #333333;
      border-radius: 3px;
      margin-right: 20px;
      &:last-child {
        margin-right: 0;
      }
      .txt {
        // height: 56px;
        // line-height: 38px;
        text-align: center;
        font-size: 14px;
        color: #999;
        margin: 5px 0;
      }
      .title {
        // height: 56px;
        // line-height: 56px;
        text-align: center;
        font-size: 20px;
        color: #333;
      }
      .btn {
        height: 46px;
        line-height: 46px;
        text-align: center;
        border: 1px solid;
        width: 130px;
        border-radius: 5px;
        margin: 0 auto;
        cursor: pointer;
        background: #ffffff;
        &:hover {
          opacity: 0.8;
        }
      }
    }
  }
  .tables {
    margin-top: 20px;
    .tabs {
      display: flex;
      margin-bottom: 20px;
      .btn-item {
        width: 130px;
        height: 46px;
        line-height: 46px;
        border-radius: 5px;
        text-align: center;
        box-sizing: border-box;
        border: 1px solid #333333;
        margin-right: 3px;
        cursor: pointer;
      }
    }
  }
}
.exchangeLog {
  position: absolute;
  right: 0;
  top: 2px;
}
</style>
